package domain;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Entity
@Access(AccessType.PROPERTY)
public class User extends Actor {

	// Constructors

	public User() {
		super();
		createdEvents = new HashSet<Project>();
		followedEvents = new HashSet<Project>();
		registrations = new HashSet<Registration>();
	}

	// Atributes
	

	// Relationships
	
	private Collection<Project> createdEvents;
	private Collection<Registration> registrations;
	private Collection<Project> followedEvents;
	private Team group;
	
	@NotNull
	@Valid
	@OneToMany(mappedBy="creator")
	public Collection<Project> getCreatedEvents() {
		return createdEvents;
	}

	public void setCreatedEvents(Collection<Project> createdEvents) {
		this.createdEvents = createdEvents;
	}

	@NotNull
	@Valid
	@OneToMany(mappedBy="user")
	public Collection<Registration> getRegistrations() {
		return registrations;
	}

	public void setRegistrations(Collection<Registration> registrations) {
		this.registrations = registrations;
	}
	
	@NotNull
	@Valid
	@ManyToMany(mappedBy="followers")
	public Collection<Project> getFollowedEvents() {
		return followedEvents;
	}

	public void setFollowedEvents(Collection<Project> followedEvents) {
		this.followedEvents = followedEvents;
	}
	
	@NotNull
	@Valid
	@ManyToOne(optional=false)
	public Team getGroup() {
		return group;
	}

	public void setGroup(Team group) {
		this.group = group;
	}
	
	
	
	
}
